package com.mentaleye.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.mentaleye.bean.StudentInterviewAnalyzeBean;
import com.mentaleye.biz.StudentInterviewAnalyzeBiz;
import com.mentaleye.util.CommonPage;
import com.mentaleye.util.CommonResult;

@Controller
@RequestMapping("/interviewAnalyzeController")
public class StudentInterviewAnalyzeController {
    
	@Autowired private StudentInterviewAnalyzeBiz recordBiz;
	
	@RequestMapping("/toListPage")
	public ModelAndView toListPage(@RequestParam long interviewId) {
		ModelAndView view = new ModelAndView("em/studentInterviewAnalyze/recordList");
		view.addObject("interviewId", interviewId);
		return view;
	}
	
	@RequestMapping("/checkUser")
	@ResponseBody
	public String checkUser(@RequestParam long recordId){
		CommonResult result = this.recordBiz.checkUser(recordId);
		return JSON.toJSONString(result);
	}
	
	
	@RequestMapping("/toEditPage")
	public ModelAndView toEditPage(@RequestParam long recordId) {
		ModelAndView view = new ModelAndView("em/studentInterviewAnalyze/recordEdit");
		view.addObject("recordBean",this.recordBiz.getBeanByKey(recordId));
		return view;
	}

	@RequestMapping("/updateData")
	@ResponseBody
	public String updateData(@RequestBody StudentInterviewAnalyzeBean recordBean) {
		CommonResult result = this.recordBiz.updateRecord(recordBean);
		return JSON.toJSONString(result);
	}

	@RequestMapping("/getList")
	@ResponseBody
	public String getList(CommonPage page) {
		this.recordBiz.getListByPage(page);
		return page.toSHowPage();
	}
}
